#
# http://en.wikipedia.org/wiki/Uptime
#
use 5.010;
use strict;

if ( -e "/proc/uptime" ) {
    printLinuxUptime();
} elsif ( -x "/bin/uptime" || -x "/usr/bin/uptime" ) {
    doUptime();
} else {
    say "I can't guess uptime";
}

sub printLinuxUptime {
    print "you are on linux so try to print linux uptime\n";
    open (F, "/proc/uptime") or die;
    my $line = <F>;
    my ($second, $idle) = split(/ /,$line);
    my $day = int($second/60/60/24);
    print "System Up Time: $day Days" . "\n";
    close (F);
}

sub doUptime {
    print "you are not on linux so try to print kinds of uptime\n";
    print `uptime`;
}
